/* SexpSerialOptions.cs -- s-expression serialization option attributes.
   Copyright (C) 2008  Casey Marshall.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.  */


using System;

namespace SexpSharp.Serialization
{
	/// <summary>
	/// Attribute that can rename types in the serialization stream.
	/// By default, the type name embedded in the serialization stream
	/// is the fully-qualified name of the C# type. Using this
	/// attribute changes the embedded name into something more
	/// general or portable.
	/// </summary>
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct
                    | AttributeTargets.Enum)]
	public sealed class SexpTypeName : Attribute
	{
		private string typeName;

		public SexpTypeName(string typeName)
		{
			this.typeName = typeName;
		}

		public string TypeName
		{
			get {
				return typeName;
			}
		}
	}

	/// <summary>
	/// Attribute that can be used to rename fields in the
	/// serialization stream. By default, the field name embedded in
	/// the serialization stream corresponds to the field's C#
	/// name. Using this attribute changes the field name in the
	/// serialization stream.
	/// </summary>
	[AttributeUsage(AttributeTargets.Field)]
	public sealed class SexpFieldName : Attribute
	{
		private string fieldName;

		public SexpFieldName(string fieldName)
		{
			this.fieldName = fieldName;
		}

		public string FieldName
		{
			get {
				return fieldName;
			}
		}
	}

	/// <summary>
	/// Tell that a type should always include its assembly name when
	/// serialized.
	/// </summary>
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct
					| AttributeTargets.Enum)]
	public sealed class SexpWithAssembly : Attribute
	{
		private bool withAssembly;

		public SexpWithAssembly() : this(true) { }

		public SexpWithAssembly(bool withAssembly)
		{
			this.withAssembly = withAssembly;
		}

		public bool WithAssembly
		{
			get {
				return withAssembly;
			}
		}
	}

	/// <summary>
	/// An attribute placed onto structs, saying that the format
	/// of the structure is "fixed", and thus it can be serialized
	/// in a more compact format, omitting names and types.
	///
	/// E.g., normally a structure:
	///
	///   struct s {
	///     bool b = true;
	///     int i = 42;
	///     string s = "Foo";
	///   }
	///
	/// Would be serialized as:
	///
	///   (s ((b (.b True)) (i (.i "42")) (s (.s "Foo"))))
	///
	/// If the struct is fixed, it can be serialized as:
	///
	///   (s (True 42 "Foo"))
	///
	/// This does mean that with a struct marked fixed you cannot add,
	/// remove, change the type of, or change the order of fields.
	///
	/// </summary>
	[AttributeUsage(AttributeTargets.Struct)]
	public sealed class SexpFixed : Attribute
	{
	}
}